package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo {
    public static void main(String[] args) {
        Collection a = new ArrayList();
        a.add(new Point(1,2));
        a.add(new Point(3,4));
        a.add(new Point(5,6));
        a.add(new Point(7,8));
        a.add(new Point(9,10));
        a.add(new Point(1,2));

        Point p = new Point(1,2);
        boolean contains = a.contains(p);
        System.out.println("是否包含:"+contains);
        /*
        从当前集合中删除与给定元素o的equals()比较为true的元素
        若存在重复元素则只删除一次
        */
        a.remove(p);
        System.out.println(a);
        //集合存放的是元素的引用
        Collection cc = new ArrayList();
        Point aa = new Point(1,2);
        cc.add(aa);//将pp添加的到cc中-----将pp的引用装到cc
        System.out.println("aa:"+aa);

        aa.setX(100);
        System.out.println("aa:"+aa);
        System.out.println("cc:"+cc);


















        /*Collection c = new ArrayList();
        c.add("abc");
        c.add("def");
        c.add("ghi");
        c.add("jkl");
        c.add("mno");
        System.out.println(c);

        System.out.println("size:"+c.size());
        System.out.println("是否为空集"+c.isEmpty());
        c.clear();//清空集合
        System.out.println("size:"+c.size());
        System.out.println("是否为空集"+c.isEmpty());*/
    }
}
